package com.example.daojia.frametest.Application;

import android.app.Application;
import android.util.Log;

import com.alibaba.android.arouter.launcher.ARouter;
import com.example.daojia.frametest.Adapter.ImageAdapter;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.taobao.weex.InitConfig;
import com.taobao.weex.WXSDKEngine;

/**
 * Created by daojia on 2018/7/24.
 */

public class myApplication extends Application {
    public static final String TAG = myApplication.class.getSimpleName() + "TAG";
    public myApplication() {
    }

    @Override
    public void onCreate() {
        Log.w(TAG, "onTerminate" + " = " + "进程开始");
        super.onCreate();
        initARouter();
        initImageLoader();
        initWeex();
    }

    private void initARouter(){
        if (true) {           // 这两行必须写在init之前，否则这些配置在init过程中将无效
            ARouter.openLog();     // 打印日志
            ARouter.openDebug();   // 开启调试模式(如果在InstantRun模式下运行，必须开启调试模式！线上版本需要关闭,否则有安全风险)
        }
        ARouter.init(this); // 尽可能早，推荐在Application中初始化
    }

    private void initImageLoader() {
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
			.build();
        ImageLoader.getInstance().init(config);
    }

    private void initWeex() {
        WXSDKEngine.initialize(this,new InitConfig.Builder()
                        .setImgAdapter(new ImageAdapter())
                        .build());
    }

    @Override
    public void onTerminate() {
        Log.w(TAG, "onTerminate" + " = " + "进程终结");
        super.onTerminate();
    }
}
